package me.wangxuan.pat.generator;

import com.formdev.flatlaf.util.StringUtils;

public enum GeneratorType {
	timestamp("timestamp","时间戳"),
	idCard("idCard","身份证");
	
	private String code;
	private String name;
	
	GeneratorType(String code, String name) {
		this.code = code;
		this.name = name;
	}
	
	public String getCode() {
		return this.code;
	}
	
	public String getName() {
		return this.name;
	}
	
	public String toString() {
		return this.name;
	}

	public static GeneratorType fromString(String str) {
        if (!StringUtils.isEmpty(str)) {
            for (GeneratorType type : GeneratorType.values()) {
                if (str.equalsIgnoreCase(type.name())) {
                    return type;
                }
            }
        }
        throw new IllegalArgumentException("Unknown GeneratorType: " + str);
    }
}
